package com.example;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.time.LocalDateTime;

@WebServlet("/test")
public class TestServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        
        // 输出系统信息和时间（用于验证部署和运行状态）
        out.println("<h1>Jenkins Test WebApp</h1>");
        out.println("<p>Current Time: " + LocalDateTime.now() + "</p>");
        out.println("<p>Server Info: " + getServletContext().getServerInfo() + "</p>");
        out.println("<p>Build Version: 1.0-SNAPSHOT</p>");
    }
}
